$(document).ready(function() {
	$("#myformulaire").submit(function() {
		$.post($(this).attr("action"), $(this).serialize(), function(reponse) {
			$("#charactersList").html(reponse);
			refreshListEvents();
		});
		return false;
	});
	
	refreshListEvents();

})
function refreshListEvents() {
	$(".destroyLink").click(function() {
		$.get($(this).attr("href"), function(reponse) {
			$("#charactersList").html(reponse);
		});
		return false;
	})
	$(".edithLink").click(function() {
		$.get($(this).attr("href"), function(reponse) {
			$("#edithFrey").html(reponse);
			refreshFormList();
		});		
		return false;
	})
}

function refreshFormList(){
	$("#didi").submit(function() {
		$.post($(this).attr("action"), $(this).serialize(), function(reponse) {
			$("#charactersList").html(reponse);
			refreshListEvents();
		});
		return false;
	});	
}
